Welcome Guest | Sign in | Register

Home > C Programming > printf() and scanf() > Questions and Answers

01. The statement which prints out the value of the integer variable sum, is
A. printf("%s", sum);

B. print("%i", sum);
C. printf("%d", sum); D. printf("%d", &sum);

Answer and Explanation

Answer: printf("%d", sum);

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
02. The statement which prints out the text string "Welcome", followed by a newline, is.
A. printf("Welcome\n"); B. printf("Welcome\n");
C. printf(Welcome\n); D. printf('Welcome', '\n');

Answer and Explanation

Answer: printf("Welcome\n");

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
03. The statement which prints out the value of the character variable letter, is
A. printf(letter); B. printf("%c", &letter);
C. printf("%c", &letter); D. printf("%c", letter);

Answer and Explanation

Answer: printf("%c", letter);

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
04. The statement which prints out the value of the float variable discount, is
A. printf("%s", discount); B. printf("%s", discount);
C. printf("%f", discount); D. printf("%d", discount);

Answer and Explanation

Answer: printf("%f", discount);

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
05. The statement which prints out the value of the float variable dump using two decimal places, is
A. printf("%f", dump); B. printf("%.2f", dump);
C. printf("%2f", dump); D. printf("%f", &dump);

Answer and Explanation

Answer: printf("%.2f", dump);

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
06. The statement to read a decimal value from the keyboard, into the integer variable sum, is
A. scanf("%d", &sum); B. scanf("%d", &sum);
C. scanf("%s", sum); D. scanf("%f", &sum);

Answer and Explanation

Answer: scanf("%d", &sum);

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
07. The statement to read a float value into the variable discount_rate is
A. scanf("%f", discount_rate); B. scanf("%d", &discount_rate);
C. scanf(discount_rate); D. scanf("%f", &discount_rate);

Answer and Explanation

Answer: scanf("%f", &discount_rate);

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
08. The statement to read a single character from the keyboard into the variable operator, skipping leading blanks, tabs and newline characters, is
A. scanf("%s", operator); B. scanf("%c", &operator);
C. scanf(" %c", &operator); D. scanf(" %c", operator);

Answer and Explanation

Answer: scanf(" %c", &operator);

Explanation:
The leading space before the modifier %c informs scanf() to skip leading whitespace characters.

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
09. What will be the output of the following program?
main()
{
printf(3+"SoftLucent"+4);
}
A. Compilation Error B. skills
C. kills D. ls

Answer and Explanation

Answer: ls

Explanation:
SoftLucent is a constant string and statement
printf(3+"SoftLucent"+4); will skip seven(3 + 4) characters of the string before printing.

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
10. What will be the output of the following program?
main()
{
printf("%c","SoftLucent"[4]);
}
A. Compilation Error B. P
C. i D. l

Answer and Explanation

Answer: i

Explanation:
SoftLucent is a constant string and character at index 4 will get printed.

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum



Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.